<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
				pageEncoding="ISO-8859-1"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="description" content="Services Directory" />
<meta name="keywords" content="Services Directory,fpt" />
<meta name="robots" content="index" />
<link rel="stylesheet" type="text/css" media="all"
				href="./Style/Style.css" />
<link rel="stylesheet" type="text/css" href="./Style/superfish.css"
				media="screen" />
<script type="text/javascript">
	jQuery(function() {
		jQuery('ul.sf-menu').superfish();
	});
</script>
<!-- Utility script: clear Data, close popup, return data to parent window -->
<script type="text/javascript">
	//clear data in text fields
	function clearForm() {
		document.getElementById("addPCode").value = '';
		document.getElementById("addStreet").value = '';
		document.getElementById("addTown").value = '';
	}
	//close popup window
	function closePopup() {
		window.open('', '_parent', '');
		window.close();
	}
	//close popup and clear data in text fields of parent window
	function goNone() {
		opener.document.getElementById("txtAdd_ID").value = '';
		opener.document.getElementById("txtAdd_pCode").value = '';
		opener.document.getElementById("txtAdd_street").value = '';
		opener.document.getElementById("txtAdd_town").value = '';
		opener.document.getElementById("txtAdd_county").value = '';
		opener.document.getElementById("txtAdd_country").value = '';
		window.close();
		return false;
	}
	//close popup and return data to parent window 
	function closeThis() {
		var radio = document.getElementsByName('rdoSelect');
		//local variable to store selected value of radio
		var addID;
		//loop through the items in radiobuttonlist
		for ( var j = 0; j < radio.length; j++) {
			if (radio[j].checked) {
				addID = radio[j].value;
				//get selected datas to pass to parent window
				var table = document.getElementById("table");
				var row = table.rows[parseInt(j) + 1];
				//get selected Address
				var cellStreet = row.cells[1];
				var addStreet = cellStreet.firstChild.nodeValue;
				//get selected PostCode
				var cellPostCode = row.cells[2];
				var addPostCode = cellPostCode.firstChild.nodeValue;
				//get selected Town
				var cellTown = row.cells[3];
				var addTown = cellTown.firstChild.nodeValue;
				//get selected County
				var cellCounty = row.cells[4];
				var addCounty = cellCounty.firstChild.nodeValue;
				//get selected Country
				var cellCountry = row.cells[5];
				var addCountry = cellCountry.firstChild.nodeValue;

				//set the appropriate data to the parent window text field
				opener.document.getElementById("txtAdd_ID").value = addID;
				opener.document.getElementById("txtAdd_pCode").value = addPostCode;
				opener.document.getElementById("txtAdd_street").value = addStreet;
				opener.document.getElementById("txtAdd_town").value = addTown;
				opener.document.getElementById("txtAdd_county").value = addCounty;
				opener.document.getElementById("txtAdd_country").value = addCountry;

				break;
			}
		}
		//close curent popup window
		window.close();
		return false;
	}
</script>
<!-- Pagination script -->
<script type="text/javascript">
	function loadpaging() {
		var curpage = document.getElementById('txtPageIndex').value;
		var maxpage = '__tag_93$17_';
		if (parseInt(curpage) > 1 && parseInt(curpage) < parseInt(maxpage)) {
			document.getElementById("btnnext").setAttribute("class", "active");
			document.getElementById("btnlast").setAttribute("class", "active");
			document.getElementById("btnpre").setAttribute("class", "active");
			document.getElementById("btnfirst").setAttribute("class", "active");
		}
		if (parseInt(curpage) == 1 && parseInt(maxpage) > 1) {
			document.getElementById("btnpre").setAttribute("class", "inactive");
			document.getElementById("btnfirst").setAttribute("class",
					"inactive");
			document.getElementById("btnnext").setAttribute("class", "active");
			document.getElementById("btnlast").setAttribute("class", "active");
		}
		if (parseInt(curpage) == parseInt(maxpage) && parseInt(maxpage) > 1) {
			document.getElementById("btnpre").setAttribute("class", "active");
			document.getElementById("btnfirst").setAttribute("class", "active");
			document.getElementById("btnnext")
					.setAttribute("class", "inactive");
			document.getElementById("btnlast")
					.setAttribute("class", "inactive");
		}
		if (parseInt(maxpage) == 1) {
			document.getElementById("btnpre").setAttribute("class", "inactive");
			document.getElementById("btnfirst").setAttribute("class",
					"inactive");
			document.getElementById("btnnext")
					.setAttribute("class", "inactive");
			document.getElementById("btnlast")
					.setAttribute("class", "inactive");
		}
	}
	function gofirstPage() {
		var curpage = document.getElementById('txtPageIndex').value;
		document.getElementById('txtPageIndex').value = 1;
		document.getElementById("btnpre").setAttribute("class", "inactive");
		document.getElementById("btnfirst").setAttribute("class", "inactive");
		document.getElementById("btnnext").setAttribute("class", "active");
		document.getElementById("btnlast").setAttribute("class", "active");
		if (parseInt(curpage) > 1) {
			document.fLookUp.submit();
		}

	}
	function golastPage() {
		var curpage = document.getElementById('txtPageIndex').value;
		var kmlString = '__tag_139$19_';
		document.getElementById('txtPageIndex').value = kmlString;
		document.getElementById("btnnext").setAttribute("class", "inactive");
		document.getElementById("btnlast").setAttribute("class", "inactive");
		document.getElementById("btnpre").setAttribute("class", "active");
		document.getElementById("btnfirst").setAttribute("class", "active");
		if (curpage < kmlString) {
			document.fLookUp.submit();
		}
	}
	function increasePage() {
		var curpage = document.getElementById('txtPageIndex').value;
		var kmlString = '__tag_151$19_';
		document.getElementById("btnpre").setAttribute("class", "active");
		document.getElementById("btnfirst").setAttribute("class", "active");
		if (parseInt(curpage) < parseInt(kmlString)) {
			document.getElementById('txtPageIndex').value = parseInt(curpage) + 1;
			if (parseInt(curpage) >= parseInt(kmlString)) {
				document.getElementById("btnnext").setAttribute("class",
						"inactive");
				document.getElementById("btnlast").setAttribute("class",
						"inactive");
			} else {
				document.fLookUp.submit();
			}
		}

	}
	function decreasePage() {
		var curpage = document.getElementById('txtPageIndex').value;
		if (curpage > 1) {
			document.getElementById('txtPageIndex').value = parseInt(curpage) - 1;
			document.getElementById("btnnext").setAttribute("class", "active");
			document.getElementById("btnlast").setAttribute("class", "active");
			if (parseInt(curpage) <= 1) {
				document.getElementById("btnpre").setAttribute("class",
						"inactive");
				document.getElementById("btnfirst").setAttribute("class",
						"inactive");
			} else {
				document.fLookUp.submit();
			}
		}

	}
</script>
<title>Address Lookup</title>
</head>
<body style="background: none; width: 940px; margin: 0 auto 0 auto;"
				onload="loadpaging();">
<div class="container" id="container">
<div id="content">
<div id="content_main" class="clearfix">
<div id="main_panel_container"><!--content-->
<h2 class="ico_mug">Search Postcode</h2>
<s:form action="AddressLookup" theme="simple" name="fLookUp">
				<div
								style="padding-top: 20px; height: 50px; border: thin solid gray; padding-left: : 10px; padding-left: 5px;">
				Postcode: <s:textfield id="addPCode" name="keyWord.postCode"
								value="%{keyWord.postCode}" cssStyle="width: 170px" /> Street:
				<s:textfield id="addStreet" name="keyWord.street"
								cssStyle="width: 280px" value="%{keyWord.street}" /> Town: <s:textfield
								id="addTown" name="keyWord.town" cssStyle="width: 280px"
								value="%{keyWord.town}" /></div>
				<div><font color="red"><s:fielderror
								value="input.required" /></font></div>
				<div
								style="margin-top: 10px; width: 100%; height: 38px; padding-left: 10px">
				<s:submit value="Search Address" /> <input type="button"
								value="None" onclick=
	goNone();;
> <input type="button"
								value="Clear" onclick=
	clearForm();;
/></div>

				<div id="tabledata" class="section"
								style="border: thin solid black; padding: 5px">
				<h3 style="color: red"><s:actionmessage /></h3>
				<table id="table">
								<thead>
												<tr>
																<th class="table_check"></th>
																<th class="table_address_address">Address</th>
																<th class="table_address_postcode">Post Code</th>
																<th class="table_address_postcode">Town</th>
																<th class="table_address_postcode">County</th>
																<th class="table_address_postcode">Country</th>
												</tr>
								</thead>
								<tbody>
												<s:iterator value="addList">
																<tr>
																				<td class="table_check"><input type="radio"
																								name="rdoSelect" class="noborder"
																								value='<s:property value="addressID" />'
																								class="noborder" /></td>
																				<td class="table_address_address"><s:property
																								value="street" /></td>
																				<td class="table_address_postcode"><s:property
																								value="postCode" /></td>
																				<td class="table_address_postcode"><s:property
																								value="town" /></td>
																				<td class="table_address_postcode"><s:property
																								value="county" /></td>
																				<td class="table_address_postcode"><s:property
																								value="country" /></td>
																</tr>
												</s:iterator>
								</tbody>
				</table>
				<div style="clear: both;"></div>

				<div class="pagination" style="background-color: #f1f1f1">
				<div id="paging_first" class="paging_first"><input
								id="btnfirst" type="button" class="active" value=" "
								onclick=
	gofirstPage();
/></div>
				<div id="paging_pre" class="paging_pre"><input id="btnpre"
								type="button" class="active" value=" " onclick=
	decreasePage();
/>
				</div>
				<div class="paging_no">|Page <s:textfield
								name="listPaging.pageNo" id="txtPageIndex" label="" size="1" />
				of <s:property value="listPaging.pageCount" /> |</div>
				<div id="paging_next" class="paging_next"><input id="btnnext"
								type="button" class="active" value=" " onclick=
	increasePage();
/>
				</div>
				<div id="paging_last" class="paging_last"><input id="btnlast"
								type="button" class="active" value=" " onclick=
	golastPage();
/>
				</div>
				</div>
				</div>
</s:form> <!-- end #tabledata -->

<div id="tableBottom" style="padding-left: 10px"><input
				type="button" value="Select" style="margin-right: 15px;"
				onclick=
	closeThis();;
> <input type="button" value="Close"
				onclick=
	closePopup();;
></div>
</div>
<!-- end #sidebar --></div>
<!-- end #content_main --></div>
<!-- end #content --></div>
<!-- end container -->

</body>
</html>